package com.wtwd.campus.sms;

import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;

/**   
* @author ldaoliang
* @date 2019年1月21日 
* Description: 发送国际短信 
*/
public class SmsToInternational {
	// Find your Account Sid and Auth Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACf82b11ff4d427a2d872cff48f2be2444";
    public static final String AUTH_TOKEN = "dddd7defe75268d0180597503ed8b4b4";
    public static final String signName = "[tracker]";
    public static final String from_phone = "+19893092688";

    public static void main(String[] args) {
    	sendVerifyCode("+6309272577462", "123456", 1);
    }
    
    public static void sendVerifyCode(String userPhone, String code, int type) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        String content = "";
        // TODO  短信内容待修改
        if (type == 1){
            content = signName + " You are registering for a new account. The validation code is" + code
                    + ".The validation information will expire in 2 minutes.";
        } else if (type == 2){
            content = signName + " You are trying to retrieve the password. The validation code is" + code
                    + ".The validation information will expire in 2 minutes.";
        } else if (type == 3){
            content = signName + " You are using mobile phone authentication. The validation code is" + code
                    + ".in order to ensure account security, please complete the authentication within 2 minutes.";
        } else {
            content = signName + " You are using mobile phone authentication. The validation code is" + code
                    + ".in order to ensure account security, please complete the authentication within 2 minutes.";
        }
        Message.creator(new PhoneNumber(userPhone), new PhoneNumber(from_phone), content).create();
    }
}
